
#include "Atm128I2C.h"

/**
 * Interface for non-blocking I2C slave engine.
 *
 * @author Laszlo Siroki
 */
interface Atm128I2CSlave
{

    /**
    * Sets the device address to respond. Responds to general call (addr. 0x00), 
    * if generalCall is TRUE
    * @param addr Device address
    * @param generalCall General call enabled
    */
    command error_t setSlaveAddress(uint8_t addr, bool generalCall);

	/**
	* Address + READ received 
	*/
	async event void startRead();

    /** Writes the byte returned to the I2C device. (Read operation from master)*/
    async event error_t readRequest ();
    
    async command void read(uint8_t data);

	/**
	* Signals reception of STOP or REPEATED START condition.
	*/
	async event void stopRead ();

	/**
	* Address + WRITE received 
	*/
	async event void startWrite();
	
    /** 
    * Byte written by master and read from the I2C bus. 
    * @return TRUE if acknowledge should be transferred, FALSE otherwise
    */
    async event bool write (uint8_t data);

	/**
	* Signals reception of STOP or REPEATED START condition.
	*/
	async event void stopWrite ();

}
